package net.loyintean.pearlshell.base.util;

import java.math.BigDecimal;

public final class BigDecimalUtil {

	private BigDecimalUtil() {
		throw new UnsupportedOperationException();
	}

	public static final BigDecimal toBigDecimal(Object numAtLeast) {
		try {
			if (numAtLeast instanceof String) {
				return new BigDecimal((String) numAtLeast);
			} else if (numAtLeast instanceof Integer) {
				return new BigDecimal((Integer) numAtLeast);
			} else if (numAtLeast instanceof Float) {
				return new BigDecimal((Float) numAtLeast);
			} else if (numAtLeast instanceof Long) {
				return new BigDecimal((Long) numAtLeast);
			} else if (numAtLeast instanceof Double) {
				return new BigDecimal((Double) numAtLeast);
			}
		} catch (Exception e) {
			throw new IllegalArgumentException(e);
		}

		throw new IllegalArgumentException("numAtLeast=" + numAtLeast);
	}

}
